<?php
header("content-type:text/html;charset=utf-8");
include "public/is_login.php";
include "../public/config/config.php";
include "../public/include/funcs.php";

if($_GET['logout'] == "logout"){
	session_destroy();
	header('location:user.php');
}
$id = $_GET['id'] ? $_GET['id'] : $_SESSION['id'];
//$id = 7;
$link=conn($cfg_dbhost,$cfg_dbuser,$cfg_dbpwd,$cfg_dbname,$cfg_dbchar);

$arr = select($link, "user", "id=$id");
$name = $arr[0]['tname'] ? $arr[0]['tname'] : $arr[0]['nickname'];
$pid = $arr[0]['pid'];
if($pid == 0){
	$str = "您是顶级会员";
}else{
	$parr = select($link, "user", "id=$pid");
	$pname = $parr[0]['tname'] ? $parr[0]['tname'] : $parr[0]['nickname'];
	$str = "您的推荐人是：".$pname."（ID：".$pid."）";
}



//echo "<pre>";
//print_r($arr);
//print_r($parr);
//echo "</pre>";
?>
<html lang="zh-CN">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
	<title>分享商城 -- 个人中心</title>
	
	<!-- Bootstrap -->
	<link href="/public/css/bootstrap.min.css" rel="stylesheet">
	<link rel="stylesheet" type="text/css" href="public/main.css"/>
	
	<!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询（media queries）功能 -->
	<!-- 警告：通过 file:// 协议（就是直接将 html 页面拖拽到浏览器中）访问页面时 Respond.js 不起作用 -->
	<!--[if lt IE 9]>
	<script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
	<script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
	<![endif]-->
	<style>

.share{
	height: 50px;
	position: relative;
	top:-52px;
	border: 1px red solid;
}

	</style>
</head>
<body>

<img src="imgs/user.png" width="100%" alt="" />
<div class="share_b">
	<a href="share.php?id=<?php echo $id;?>">
		<div class="share"></div>
	</a>
</div>

<p>当前登录账号：<?php echo $name;?></p>
<p>当前账号ID：<?php echo $id ? $id : "重新登录可显示。";?></p>
<p><?php echo $str;?></p>
<a href="user.php?logout=logout">退出登录</a>

<?php include "template/footer.php";?>

<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
<script type="text/javascript" src="/public/js/jquery-3.3.1.min.js"></script>
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script type="text/javascript" src="/public/js/bootstrap.min.js"></script>
</body>
</html>